package com.njts.servlet;

import com.njts.auto.AutoCreateBean;
import com.njts.auto.AutoSearch;
import com.njts.dao.UseDao;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/courseDeleteById")
public class CourseDeleteServlet extends HttpServlet {
    UseDao useDao=new UseDao();
    AutoCreateBean autoCreateBean=new AutoCreateBean();
    AutoSearch autoSearch=new AutoSearch();

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setCharacterEncoding("utf-8");
        int id = Integer.parseInt(req.getParameter("id"));
        boolean b = useDao.deleteCourse(id);
        PrintWriter writer = resp.getWriter();
        if(b) {
            writer.write("200");
        }else{
            writer.write("500");
        }
    }
}
